<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
var inorderTraversal = function(root) {
    let res = []
    let stack = []
    let node = root
    while(stack.length || node){
        while(node){
            stack.push(node)
            node = node.left
        }
        node = stack.pop()
        res.push(node.val)
        node = node.right
    }
    return res
};
    </script>
</body>
</html>